# 水印添加到INV1.pdf中

from PyPDF2 import PdfFileReader, PdfFileWriter
from copy import copy

watermark_pdf = PdfFileReader(r'watermark.pdf')
watermark_page = watermark_pdf.getPage(0)

pdf_reader = PdfFileReader('INV1.pdf')
pdf_writer = PdfFileWriter()

for page in range(pdf_reader.getNumPages()):
    origin_page = pdf_reader.getPage(page)
    new_page = copy(watermark_page)
    new_page.mergePage(origin_page)
    # pdf_writer.addPage(new_page)

# 「加密是针对写入器加密」
# pdf_writer.encrypt('123')
with open('INV-with-wm.pdf', 'wb') as out:
    pdf_writer.write(out)
